var ClubAssistantUnit = Unit.extend({
    _ccsFileName: res.ClubAssistantUnit_json,
    _clubId: null,
    _posFlag: -1,
    initUnit: function (target, clubId) {
        this._clubId = clubId;
        clubMsgManager.requestClubBaseInfo(clubId);
        //this._nodeList['assistantNode'].setVisible(false);
        this._nodeList['assistantNode'].setPositionX(-300);
        this._nodeList['touchLayer'].setVisible(false);
        this._posFlag = -1;
    },

    onEnter:function(){
        cc.Node.prototype.onEnter.call(this);
        //this._nodeList['assistantNode'].setVisible(false);
        this._nodeList['assistantNode'].setPositionX(-300);
        this._nodeList['touchLayer'].setVisible(false);
    },
    _initClickListeners: function () {
        this._clickListeners = {
            'btn_assistant': '_clickAssistant',
            'touchLayer': '_clickTouchLayer',
            'assistantNode.btn_inviteOnline': '_clickInviteOnLine',
            'assistantNode.btn_showHall': '_clickShowTableWindow',
        }
    },

    _clickAssistant: function () {
        var self = this;
        if (self._posFlag == 0) return;
        if (self._posFlag == -1){
            self._posFlag = 0;
            self._nodeList['touchLayer'].setVisible(false);
            self._nodeList['assistantNode'].setPositionX(-300);
            self._nodeList['assistantNode'].runAction(cc.sequence(
                cc.moveTo(0.5, cc.p(0,0)),
                cc.callFunc(function () {
                    self._nodeList['touchLayer'].setVisible(true);
                    self._posFlag = 1;
                })
            ));
        }
        else if (self._posFlag == 1) {
            self._posFlag = 0;
            self._nodeList['touchLayer'].setVisible(false);
            self._nodeList['assistantNode'].setPositionX(0);
            self._nodeList['assistantNode'].runAction(cc.sequence(
                cc.moveTo(0.5, cc.p(-300,0)),
                cc.callFunc(function () {
                    self._posFlag = -1;
                })
            ));
        }
        //this._nodeList['assistantNode'].x = display.width - this._nodeList['assistantNode'].getContentSize().width * 0.5 - 20;
        //this._nodeList['assistantNode'].setVisible(!this._nodeList['assistantNode'].isVisible());
        //this._nodeList['touchLayer'].setVisible(!this._nodeList['touchLayer'].isVisible());
    },

    _clickTouchLayer: function () {
        //this._nodeList['assistantNode'].setVisible(false);
        var self = this;
        if (self._posFlag == 0) return;
        if (self._posFlag == 1) {
            self._posFlag = 0;
            self._nodeList['touchLayer'].setVisible(false);
            self._nodeList['assistantNode'].setPositionX(0);
            self._nodeList['assistantNode'].runAction(cc.sequence(
                cc.moveTo(0.5, cc.p(-300,0)),
                cc.callFunc(function () {
                    self._posFlag = -1;
                })
            ));
        }
    },

    _clickInviteOnLine: function () {
        showWindow('ClubAssistantInviteWindow', this._clubId);
    },

    _clickShowTableWindow: function () {
        // var clubTableWindow = showWindow('ClubTableWindow', this._clubId);
        // if (clubTableWindow) {
        //     clubTableWindow.open(this._clubId);
        //     clubTableWindow.setRoomStyleClub(true);
        // }
        // ClubViewUtil.openRoomClubTableWindow(this._clubId);
        // if (ClubViewUtil.RoomClubTableWindow) {
        //     ClubViewUtil.RoomClubTableWindow.setRoomStyleClub(true);
        // }
        ClubViewUtil.openClubTableWindow(this._clubId);
        if (ClubViewUtil.ClubTableWindow) {
            ClubViewUtil.ClubTableWindow.setRoomStyleClub(true);
        }

    },
});